﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace PocketGPW
{
    internal static class HTTPHelper
    {
        internal static HttpWebRequest CreateRequest(string query)
        {
            HttpWebRequest request;

            try
            {
                request = (HttpWebRequest)HttpWebRequest.Create(query);
            }
            catch
            {
                return null;
            }

            request.Timeout = 10000;
            request.Method = "GET";
            request.KeepAlive = false;

            return request;
        }

        internal static string ReadResponse(HttpWebResponse response)
        {
            string s = String.Empty;

            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                s = sr.ReadToEnd();
                sr.Close();
            }

            return s;
        }
    }
}
